#encoding = utf-8
#! /usr/sbin
#登出
from excelword.config import host,user,password,headers
import requests
#加上避免python警告看着难受
from requests.packages.urllib3.exceptions import InsecureRequestWarning
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
import json
def logout():
    login_url = "https://"+host+"/api/v1/namespaces/test-cli/logout"
    try:
        logout_response = requests.post(url=login_url, headers=headers, data=None, verify=False)
        json_data = logout_response.text   #其值为str
        if(json.loads(json_data)["code"]== 0):
            return "---logout success----"
        else:
            return "----logout failed----"
        # str(json.loads(json_data)["message"]) == "message":
    except Exception as e:
         print("获取token产生异常，异常信息为:{error_message}".format(error_message=e))
         return None
         sys.exit(0)

if __name__ == '__main__':
    #测试入口
    logout()